import os


class TenXClass:
    def __init__(self):
        # 获取当前文件名并截取文件名的学号-姓名
        file_name = os.path.basename(__file__).split('.')[0].split("-")
        self.id = file_name[0]  # 学号
        self.name = file_name[1]  # 姓名

    @staticmethod
    def question1(*args) -> list[str]:
        binary_tree = args[0]  # 传入的地牢结构（二叉树），详细请看BinaryTree.py
        result = []
        node = binary_tree.root

        def collect_tree(string, _node):
            new_string = string + str(_node.value)
            if _node.left is None and _node.right is None:
                if _node.value == 0:
                    result.append(new_string)
                return
            collect_tree(new_string, _node.left)
            collect_tree(new_string, _node.right)

        collect_tree("", node)
        return result

    @staticmethod
    def question2(*args) -> str:
        result = ""
        matrix = args[0]  # 传入的河流结构（矩阵）
        for row in matrix:
            result = result + str(max(row))
        return result

    @staticmethod
    def question3(*args) -> int:
        return 52808343  # (6 * 7 ** 999 - 5 * 6 ** 999) % 99999999

    @staticmethod
    def question4(*args) -> int:
        n = args[0]  # 用于搭建金字塔的球个数
        for i in range(n):
            if i * (i + 1) * (i + 2) / 6 > n:
                return i - 1

    @staticmethod
    def question5(*args) -> list[str]:
        balls = args[0].copy()  # 五行空间球的初始值
        while True:
            for i in range(5):
                if min(balls) >= 10000:
                    break
                balls[i] = balls[(i - 2) % 5] + balls[(i - 1) % 5]
            if min(balls) >= 10000:
                break
        return list(map(str, balls))
